package cn.com.elite;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.OutputStream;

import org.apache.commons.httpclient.methods.multipart.FilePart;
import org.apache.commons.httpclient.methods.multipart.FilePartSource;
import org.apache.commons.httpclient.util.EncodingUtil;

public class EncodingFilePart extends FilePart{
    public EncodingFilePart(String name, String fileName, File file, String contentType, String charset)
    throws FileNotFoundException{
    	super(name, new FilePartSource(fileName, file), contentType, charset);
    }

protected void sendDispositionHeader(OutputStream out)
    throws IOException{
	super.sendDispositionHeader(out);
	String filename=super.getSource().getFileName();
	if(filename!=null){
	    out.write(EncodingUtil.getAsciiBytes(FILE_NAME));
	    out.write(QUOTE_BYTES);
	    out.write(EncodingUtil.getBytes(filename, getCharSet()));
	    out.write(QUOTE_BYTES);
	}
}

}
